/*
 * Copyright (c) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import mixpanel from 'mixpanel_ohos';

export default {
  data: {
    title: '',
    token: '9b164f424c15d9d59b71efa4d9403a97', // replace with your mixpanel token id
    distinctId: 'mixpanel_hmos_ohos',
    batchEvents: [
      {
        'event': 'Event1',
        'properties': {
          'time': new Date(),
          'key': 'ohos_key'
        }
      },
      {
        'event': 'Event2',
        'properties': {
          'time': new Date()
        }
      }],
    mPanel: '',
    people: '',
    groupKey: 'All',
    groupId: 'ohos_chris',
  },
  onInit() {
    this.title = 'Mixpanel - HMOS';
    this.mpanel = mixpanel.init(this.token);
    this.people = new mixpanel.MixpanelPeople(this.mpanel);
    this.group = new mixpanel.MixpanelGroups(this.mpanel)
  },
  onButtonTrackClick() {
    this.mpanel.track('Button Click Track');
  },
  onButtonBatchClick() {
    this.mpanel.trackBatch(this.batchEvents);
  },
  onButtonPeopleSetOnceClick() {
    this.people.setOnce(this.distinctId, {
      'place': 'Ahmedabad',
      'Date': '23 Dec 2021'
    });
  },
  onButtonPeopleSetClick() {
    this.people.set(this.distinctId, {
      'gender': 'male',
      'age': '28'
    });
  },
  onButtonPeopleIncrementClick() {
    this.people.increment(this.distinctId, {
      'id': 1000,
      'page_views': 500,
      'count': -200,
    });
  },
  onButtonPeopleAppendClick() {
    this.people.append(this.distinctId, {
      list1: 'OHOS',
      list2: 123
    });
  },
  onButtonPeopleTrackClickCharge() {
    this.people.trackCharge(this.distinctId, 1000);
  },
  onButtonPeopleClearClickCharge() {
    this.people.clearCharges(this.distinctId);
  },
  onButtonPeopleRemoveClick() {
    this.people.remove(this.distinctId, {
      list1: 'OHOS'
    });
  },
  onButtonPeopleUnionClick() {
    this.people.union(this.distinctId, {
      list1: 'OHOS'
    });
  },
  onButtonPeopleUnsetClick() {
    this.people.unset(this.distinctId, ['list1', 'list2']);
  },
  onButtonPeopleDeleteClick() {
    this.people.deleteUser(this.distinctId);
  },
  onButtonGroupSetOnceClick() {
    this.group.setOnce(this.groupKey, this.groupId, {
      'name': 'OHOS',
      'age': '21',
    });
  },
  onButtonGroupSetClick() {
    this.group.set(this.groupKey, this.groupId, {
      'name': 'santa',
      'age': '26',
    });
  },
  onButtonGroupRemoveClick() {
    this.group.remove(this.groupKey, this.groupId, {
      'age': '21'
    });
  },
  onButtonGroupUnionClick() {
    this.group.union(this.groupKey, this.groupId, {
      'age': '21'
    });
  },
  onButtonGroupUnsetClick() {
    this.group.unset(this.groupKey, this.groupId, 'age');
  },
  onButtonGroupDeleteClick() {
    this.group.deleteGroup(this.groupKey, this.groupId);
  }
}